package com.song.cloud.service.impl;

import com.song.cloud.dao.BookDao;
import com.song.cloud.pojo.Book;
import com.song.cloud.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2024/1/2
 * @Version 1.0
 **/
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookDao bookDao;

    @Override
    public List<Book> findAll() {
        return this.bookDao.findAll();
    }

    @Override
    public Book findById(Integer id) {
        return this.bookDao.findById(id).get();
    }

    @Override
    public void save(Book book) {
         this.bookDao.save(book);
    }

    @Override
    public void update(Book book) {
          this.bookDao.saveAndFlush(book);
    }

    @Override
    public void delete(Integer id) {
          this.bookDao.deleteById(id);
    }
}
